//
//  PCDApiClearStorage.m
//  PCDBank
//
//  Created by lyy on 2021/3/17.
//  Copyright © 2021 DK. All rights reserved.
//

#import "PCDApiClearStorage.h"
#import "PCDDataBaseModel.h"

@implementation PCDApiClearStorage

- (void)handler:(id)data andContext:(PCDContext *)context ResponseCallback:(WVJBResponseCallback)responseCallback {
    
    NSDictionary *parameters = (NSDictionary *)data;
    NSString *callBack = [parameters objectForKey:@"success"];
    
    if ([[[PCDDataBaseModel shareModel].memoryStorage allKeys] containsObject:kPCDLoginSessionKey]) {
        NSString *loginSession = [[PCDDataBaseModel shareModel].memoryStorage objectForKey:kPCDLoginSessionKey];
        [[PCDDataBaseModel shareModel].memoryStorage removeAllObjects];
        [[PCDDataBaseModel shareModel].memoryStorage setObject:loginSession forKey:kPCDLoginSessionKey];
    } else {
        [[PCDDataBaseModel shareModel].memoryStorage removeAllObjects];
    }
    [[PCDDataBaseModel shareModel] clearStorageFromDataBase];

    evaluateJavaScriptOnMainThread_quotes(self, callBack, @"");
    
}

@end
